package com.hardware.controller;

import com.hardware.entity.AidierInit;
import com.hardware.entity.CardInfo;
import com.hardware.entity.Respond;
import com.hardware.service.AidierService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 爱迪尔门锁
 *
 * @作者 韩宗森
 * @创建时间 2024年11月4日 12:49
 */

@Tag(name = "爱迪尔门锁接口")
@RestController
@RequestMapping("/hard/aidier")
public class AidierController {

    // 门锁
    @Autowired
    private AidierService aidierService;

    // http://127.0.0.1:8080/hard/jinglun
    @Operation(summary = "初始化接口")
    @PostMapping("/init")
    public Respond aidierInit(@RequestBody AidierInit aidierInit) {

        return aidierService.initDoorInterface(aidierInit);
    }

    @Operation(summary = "关闭资源接口")
    @GetMapping("/close")
    public Respond close() {

        return aidierService.close();
    }

    @Operation(summary = "发卡")
    @PostMapping("/new-card")
    public Respond<CardInfo> newCard(@RequestBody CardInfo cardInfo) {

        return aidierService.newCard(cardInfo);
    }

    @Operation(summary = "读卡")
    @GetMapping("/read-card")
    public Respond<CardInfo> readCard() {

        return aidierService.readCard();
    }

    @Operation(summary = "销卡")
    @PostMapping("/destroy-card")
    public Respond<CardInfo> destroyCard(@RequestBody CardInfo cardInfo) {

        return aidierService.destroyCard(cardInfo);
    }


    @Operation(summary = "beep(蜂鸣器)")
    @GetMapping("/beep")
    public Respond destroyCard() {

        return aidierService.beep();
    }
}
